{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "尝试一下While语法"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "def my_simple_while_usecase():\n",
    "    loop_round = 10\n",
    "    while loop_round >= 0:\n",
    "        #print(loop_round)\n",
    "        loop_round -= 1\n",
    "    print(\"The final loop_round value is:\", loop_round)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The final loop_round value is: -1\n"
     ]
    }
   ],
   "source": [
    "my_simple_while_usecase()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "我们尝试一个简单的双指针的访问办法"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "def my_simple_two_points_while_usecase():\n",
    "    my_array = [1, 2, 3, 4, 5]\n",
    "    index_i,index_j = 0, 4\n",
    "    while index_i < index_j:\n",
    "        print(my_array[index_i], my_array[index_j])\n",
    "        index_i += 1\n",
    "        index_j -= 1\n",
    "    print(\"The final index_i value is:\", index_i)\n",
    "    print(\"The final index_j value is:\", index_j)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1 5\n",
      "2 4\n",
      "The final index_i value is: 2\n",
      "The final index_j value is: 2\n"
     ]
    }
   ],
   "source": [
    "my_simple_two_points_while_usecase()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "science39",
   "language": "python",
   "name": "science39"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.18"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
